package com.fer.t1.client.pages.multiStep;

import java.util.Map;

import com.fer.t1.client.HistoryManager;

public abstract class MultiStepHistoryManager extends HistoryManager{

	public final static String STEP = "step";
		

	@Override
	public void onHistoryChange(Map<String, String> params) {
		
		
		String stepString = params.get(STEP);
		if (stepString == null)
		{
			int step = 0;
			getPresenter().setStep(step);
		}
		else
		{
			int step = Integer.parseInt(stepString)-1;
			getPresenter().setStep(step);
			
		}
		onHistoryChanged(params);
		draw();
	}
	@Override
	public void onHistoryChange() {
		int step = 0;
		getPresenter().setStep(step);
		super.onHistoryChange();
	}
	
	public MultiStepHandler getPresenter()
	{
		return (MultiStepHandler) handler;
	}
	
	public abstract void onHistoryChanged(Map<String,String> params);
}
